	queue= function(type, fn){

		if ( jQuery.isFunction(type) ) {
			fn = type;
			type = "fx";
		}

		if ( !type || (typeof type == "string" && !fn) )
			return queueiMethods( this[0], type );

		return this.each(function(){
			if ( fn.constructor == Array )
				queueiMethods(this, type, fn);
			else {
				queueiMethods(this, type).push( fn );
			
				if ( queueiMethods(this, type).length == 1 )
					fn.apply(this);
			}
		});
	}

  var queueiMethods = function( elem, type, array ) {
	if ( !elem )
		return;

	var q = jQuery.data( elem, type + "queue" );

	if ( !q || array )
		q = jQuery.data( elem, type + "queue", 
			array ? jQuery.makeArray(array) : [] );

	return q;
 }
